package com.mifengs.mall.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mifengs.mall.R;
import com.mifengs.mall.entity.MsgBean;
import com.mifengs.mall.util.ImageLoadUtil;

import java.util.List;

/**
 * Created by lynn on 2018/1/12.
 */

public class MsgCenterAdapter extends BaseMultiItemQuickAdapter<MsgBean,BaseViewHolder> {

    private Context mContext;

    public MsgCenterAdapter( List<MsgBean> msgBeanList, Context mContext) {
        super(msgBeanList);
        this.mContext = mContext;
        addItemType(MsgBean.MSG_IMG,R.layout.item_promotion_msg);
        addItemType(MsgBean.MSG_TEXT,R.layout.item_msg_center);
    }

    @Override
    protected void convert(BaseViewHolder helper, MsgBean item) {
        switch (helper.getItemViewType()){
            case MsgBean.MSG_TEXT:
                helper.setText(R.id.tv_title,item.getRecordListBean().getTitle()).setText(R.id.tv_content,item.getRecordListBean().getContent());
                helper.setText(R.id.tv_time,item.getRecordListBean().getPushTime());
                break;
            case MsgBean.MSG_IMG:
                helper.setText(R.id.tv_title,item.getRecordListBean().getTitle()).setText(R.id.tv_content,item.getRecordListBean().getContent());
                helper.setText(R.id.tv_time,item.getRecordListBean().getPushTime());
                ImageView imageView = helper.getView(R.id.pro_img);
                new ImageLoadUtil().displayImage(mContext,item.getRecordListBean().getImgUrl(),imageView);
                break;
        }

    }
}
